/*
* Copyright 2005-2008 Pulse Technologies. Tutti i diritti riservati.
*/
package org.obsidianrad.server.services.obj2db.dao;

import org.obsidianrad.server.services.ObsModel;
import org.obsidianrad.server.services.obj2db.commodities.Filterer;
import org.obsidianrad.server.services.obj2db.commodities.PagingLoadConfig;
import org.obsidianrad.server.services.obj2db.commodities.PagingLoadResult;
import org.obsidianrad.utils.ObjProxyException;
import org.obsidianrad.utils.Token;
import org.obsidianrad.utils.obsobserver.AbstractObsidianSubjectAndObserver;


/**
 * 
 * @author Eligio Colutta
 * @version $Rev: 88 $
 * @lastautorcommit $Author: eliosh $
 * @lastdatecommit $Date: 2010-02-01 10:41:41 +0100(lun, 01 feb 2010) $
 */
public abstract class GenericProxyImpl<T extends ObsModel> extends AbstractObsidianSubjectAndObserver implements GenericProxy<T> {


	protected GenericDAO<T> dao;

	/**
	 * Metodo per recuperare il tipo di oggetto con il quale creiamo questa classe.
	 * Necessario al fine di sapere quale classe è capace di gestire un generico oggetto X
	 * @return Stringa che rappresenta il generic class name del tipo
	 */
	public abstract String getTypeClass();
	
	public GenericDAO<T> getDao() {
		return dao;
	}

	public void setDao(GenericDAO<T> dao) {
		this.dao = dao;
	}


	@Override
	public Integer deleteMany(Filterer reference) throws ObjProxyException {
		return dao.deleteMany(reference);
	}

	@Override
	public void deleteOne(T reference, Token<T> token) throws ObjProxyException {
		dao.deleteOne(reference);
	}

	@Override
	public PagingLoadResult<T> getList(T reference, PagingLoadConfig config) throws ObjProxyException {
		return dao.getList(reference, config);
	}

	@Override
	public PagingLoadResult<T> getList(Filterer reference, PagingLoadConfig config) throws ObjProxyException {
		return dao.getList(reference, config);
	}

	@Override
	public T getSingle(T reference) throws ObjProxyException {
		return dao.getSingle(reference);
	}

	@Override
	public String save(T reference) throws ObjProxyException {
		return dao.save(reference);
	}

	@Override
	public T updateOne(T reference, Token<T> token) throws ObjProxyException {
		return dao.updateOne(reference);
	}

	@Override
	public int updateMany(Filterer reference) throws ObjProxyException {
		return dao.updateMany(reference);
	}

}
